package com.njbw.design_pattern.struct.bridge;

import com.njbw.design_pattern.struct.bridge.abstractor.Driver;
import com.njbw.design_pattern.struct.bridge.abstractor.DriverManagerOne;
import com.njbw.design_pattern.struct.bridge.implementor.MysqlDriver;
import com.njbw.design_pattern.struct.bridge.implementor.OracleDriver;

public class Main {

    public static void main(String[] args) throws Exception {
        // 先创建一个驱动实例，我们可以通过反射来构建
        // Driver driver = new MysqlDriver();
        // Driver driver = new OracleDriver();
        Class<? extends Driver> driverClass = (Class<? extends Driver>) Class.forName("com.njbw.design_pattern.struct.bridge.implementor.MysqlDriver");
        Driver driver = driverClass.newInstance();
        // 注册给 DriverManager
        DriverManagerOne driverManager = new DriverManagerOne();
        driverManager.register(driver);
        // 获取连接
        driverManager.getConnection();
    }
}
